// @FileName  :itob.c
// @Time      :2024/2/29 22:28
// @Author    :YKW
//# include <bits/stdc++.h>
//using namespace std;
# include <stdio.h>
# include <stdlib.h>
# include <math.h>
# include <string.h>
# include <stdlib.h>

void solve() {
    char h[50] = "0123456789abcdefghijklmnopqrstuvwxyz", ans[50];
    int n, b, cnt = 0,f=0;
    scanf("%d%d", &n, &b);
    if(n<0)f=1,n=-n;
    while (n > 0) {
        ans[cnt++] = h[n % b];
        n /= b;
    }
    if(f==1)printf("-");
    while (cnt--)printf("%c", ans[cnt]);
}

void main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) solve();
    return 0;
}